#include <bits/stdc++.h>
using namespace std;

const int mod = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;

	vector<pair<int, int>> a(n);

	for (int i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second;
	}

	int x = a[0].first;
	int y = a[0].second;

	for (int i = 1; i < n; i++) {
		int a1 = x, b1 = y;
		int a2 = a[i].first, b2 = a[i].second;

		x = (1LL * a1 * a2 - 1LL * b1 * b2) % mod;
		y = (1LL * a1 * b2 + 1LL * b1 * a2) % mod;

		if (x < 0) x += mod;
		if (y < 0) y += mod;
	}

	cout << x << " " << y << endl;
}
